<?php
/**
 * @author zhangxin
 * @desc 邮件发送
 */
class MailController extends Yaf_Controller_Abstract
{
    public function sendAction()
    {
        $submit = Common_Request::getRequest("submit", "0");
        if ($submit != "1") {
            echo Common_Request::Response(-3001, "请通过正确渠道提交");
            return false;
        }

        //获取参数
        $uid      = Common_Request::postRequest("uid", false);
        $title    = Common_Request::postRequest("title", false);
        $contents = Common_Request::postRequest("contents", false);

        if (!$uid || !$title || !$contents) {
            echo Common_Request::Response(-3002, "用户ID、邮件标题、邮件内容均不能为空");
            return false;
        }

        //发送邮件
        $model = new MailModel();
        if ($model->send(intval($uid), trim($title), trim($contents))) {
            echo Common_Request::Response(0);
            return true;
        } else {
            echo Common_Request::Response($model->errno, $model->errmsg);
            return false;
        }
    }
}
